<template>
  <view class="commission-details" ref="container">
<!--    <view class="promoterHeader bg-color-red">
      <view class="headerCon acea-row row-between-wrapper">
        <view>
          <view class="name">会员总数</view>
          <view class="money">
            <text class="num">{{ count }}</text>
          </view>
        </view>
      </view>
    </view> -->
    <view class="sign-record" ref="content">
      <view class="list">
		 <view class="listn" v-for="(item, indexn) in info" :key="indexn" style="padding: 10rpx;">
		  	<view class="itemn acea-row row-between-wrapper " >
		  		<view>
		  			<image style="width: 60rpx;height: 60rpx; vertical-align: bottom;" :src="item.avatar" mode=""></image>
		  		</view>
		  		<view>{{item.nickname}}</view>
		  		<view>月销售额{{item.salesVolume}}元</view>
		  	</view>
		  </view>
		  
  <!--      <view class="list-item" v-for="(item, infoIndex) in info" :key="infoIndex">
          <view class="data">
			  <image style="width: 60rpx;height: 60rpx; vertical-align: bottom;" :src="item.avatar" mode=""></image>
		  </view>
        <view class="data">
        			{{item.nickname}}
        </view>
		<view class="data">
					订单数 ({{item.orderCount}})
		</view>
        </view> -->
		
      </view>
    </view>
    <Loading :loaded="loaded" :loading="loading"></Loading>
  </view>
</template>
<script>
// import { getCommissionInfo, getSpreadInfo } from "@/api/user";
import {
		monthlyRankings
	} from "@/api/admin";
import Loading from "@/components/Loading";

export default {
  name: "CashRecord",
  components: {
    Loading
  },
  props: {},
  data: function() {
    return {
      info: [],
      commission: 0,
      where: {
        page: 0,
        limit: 10,
      },
      types: 1,
      loaded: false,
      loading: false,
	  count:0,
	  typeMap: {
	  	'pay_product': '消费',
	  	'recharge': '充值',
	  	'brokerage': '返佣',
	  	'extract': '提现',
	  	'sign': '签到积分',
	  	'pay_product_refund': '退款',
	  	'system_add': '系统增加',
	  	'system_sub': '系统减少',
	  	'deduction': '减去',
	  	'gain': '奖励',
	  	'price_difference': '差价'
	  },
	  nowMoney: 0
    };
  },
  mounted: function() {
    // this.getCommission();
    // this.getIndex();
	this.nowMoney = this.$yroute.query.nowMoney
	this.loadData()
  },
  onReachBottom() {
    this.loading === false && this.getIndex();
  },
  methods: {
	  loadData() {
	  	let that = this;
	  	monthlyRankings(that.where).then(
	  		res => {
	  			that.loading = false;
	  			that.loaded = res.data.totalElements < that.where.limit;
	  			that.where.page = that.where.page + 1;
				that.count=res.data.totalElements
	  			that.info.push.apply(that.info, res.data.content);
	  		},
	  		err => {
	  			uni.showToast({
	  				title: err.msg || err.response.data.msg || err.response.data.message,
	  				icon: 'none',
	  				duration: 2000
	  			});
	  		}
	  	);
	  },
    getIndex: function() {
      let that = this;
      if (that.loading == true || that.loaded == true) return;
      that.loading = true;
      getCommissionInfo(that.types).then(
        res => {
          that.loading = false;
          that.loaded = res.data.length < that.where.limit;
          that.where.page = that.where.page + 1;
          that.info.push.apply(that.info, res.data);
        },
        err => {
          uni.showToast({
				title: err.msg || err.response.data.msg|| err.response.data.message,
				icon: 'none',
				duration: 2000
			});
        }
      );
    },
	goRouter(url) {
		this.$yrouter.push({path: url});
	}
  }
};
</script>
<style scoped lang="less">
	.list-item{
		display: flex;
		    align-items: center;
		    justify-content: space-around;
			margin: 30rpx 0;
			    height: 60rpx;
			    line-height: 60rpx;
	}
</style>

